import Vue from 'vue'
import Router from 'vue-router'

Vue.use(Router)

/* Layout */
import Layout from '@/layout'
import LayoutT1 from '@/layout/layoutT1'
import LayoutT2 from '@/layout/layoutT2'

/* Router Modules */
// import componentsRouter from './modules/components'
// import chartsRouter from './modules/charts'
// import tableRouter from './modules/table'
// import nestedRouter from './modules/nested'

/**
 * Note: sub-menu only appear when route children.length >= 1
 * Detail see: https://panjiachen.github.io/vue-element-admin-site/guide/essentials/router-and-nav.html
 *
 * hidden: true                   if set true, item will not show in the sidebar(default is false)
 * alwaysShow: true               if set true, will always show the root menu
 *                                if not set alwaysShow, when item has more than one children route,
 *                                it will becomes nested mode, otherwise not show the root menu
 * redirect: noRedirect           if set noRedirect will no redirect in the breadcrumb
 * name:'router-name'             the name is used by <keep-alive> (must set!!!)
 * meta : {
    roles: ['admin','editor']    control the page roles (you can set multiple roles)
    title: 'title'               the name show in sidebar and breadcrumb (recommend set)
    icon: 'svg-name'/'el-icon-x' the icon show in the sidebar
    noCache: true                if set true, the page will no be cached(default is false)
    affix: true                  if set true, the tag will affix in the tags-view
    breadcrumb: false            if set false, the item will hidden in breadcrumb(default is true)
    activeMenu: '/example/list'  if set path, the sidebar will highlight the path you set
  }
 */

/**
 * constantRoutes
 * a base page that does not have permission requirements
 * all roles can be accessed
 */
export const constantRoutes = [
  {
    path: '/redirect',
    component: Layout,
    hidden: true,
    children: [
      {
        path: '/redirect/:path(.*)',
        component: () => import('@/views/redirect/index')
      }
    ]
  },
  {
    path: '/login',
    component: () => import('@/views/login/index'),
    hidden: true
  },
  {
    path: '/auth-redirect',
    component: () => import('@/views/login/auth-redirect'),
    hidden: true
  },
  {
    path: '/404',
    component: () => import('@/views/error-page/404'),
    hidden: true
  },
  {
    path: '/401',
    component: () => import('@/views/error-page/401'),
    hidden: true
  },
  {
    path: '/',
    component: Layout,
    redirect: '/dashboard',
    children: [
      {
        path: 'dashboard',
        component: () => import('@/views/dashboard/index'),
        name: 'Dashboard',
        meta: { title: '首页', icon: 'dashboard', affix: true }
      }
    ]
  },
  // {
  //   path: '/guide',
  //   component: Layout,
  //   redirect: '/guide/index',
  //   children: [
  //     {
  //       path: 'index',
  //       component: () => import('@/views/guide/index'),
  //       name: 'Guide',
  //       meta: { title: 'Guide', icon: 'guide', noCache: true }
  //     }
  //   ]
  // },
  {
    path: '/profile',
    component: Layout,
    redirect: '/profile/index',
    hidden: true,
    children: [
      {
        path: 'index',
        component: () => import('@/views/profile/index'),
        name: 'Profile',
        meta: { title: 'Profile', icon: 'user', noCache: true }
      }
    ]
  }
]

/**
 * asyncRoutes
 * the routes that need to be dynamically loaded based on user roles
 */
export const asyncRoutes = [
  {
    path: '/appdata',
    component: Layout,
    alwaysShow: true, // will always show the root menu
    name: 'AppData',
    meta: {
      title: '系统设置',
      icon: 'example',
      roles: ['admin'] // you can set roles in root nav
    },
    children: [
      {
        path: 'version',
        component: () => import('@/views/appdata/versioninfo'),
        name: 'VersionManage',
        meta: {
          title: '版本管理',
          roles: ['admin'] // or you can only set roles in sub nav
        }
      },
      {
        path: 'banner',
        component: () => import('@/views/appdata/bannerinfo'),
        name: 'BannerManage',
        meta: {
          title: 'Banner管理',
          roles: ['admin'] // or you can only set roles in sub nav
        }
      },
    ]
  },
  {
    path: '/usermanage',
    component: Layout,
    alwaysShow: true,
    meta: {
      title: '用户管理',
      icon: 'peoples',
      roles: ['admin'] // you can set roles in root nav
    },
    children: [
      
      {
        path: 'userlist',
        component: () => import('@/views/users/userlist'),
        name: 'UserList',
        meta: { 
          title: '用户管理',
          roles:['admin']
        }
      },
      {
        path: 'userdetails/:id',
        component: () => import('@/views/users/userdetails'),
        name: 'UserDetails',
        meta: { 
          title: '用户详情',
          roles:['admin']
        },
        hidden:true
      },
    ]
  },
  {
    path: '/membermanage',
    component: Layout,
    alwaysShow: true,
    meta: {
      title: '会员中心',
      icon: 'peoples',
      roles: ['admin'] // you can set roles in root nav
    },
    children: [
      
      {
        path: 'memberlist',
        component: () => import('@/views/users/userlist'),
        name: 'UserList',
        meta: { 
          title: '会员列表',
          roles:['admin']
        }
      },
      {
        path: 'memberdetails/:id',
        component: () => import('@/views/users/userdetails'),
        name: 'UserDetails',
        meta: { 
          title: '用户详情',
          roles:['admin']
        },
        hidden:true
      },
    ]
  },
  {
    path: '/presalemanage',
    component: LayoutT1,
    alwaysShow: true,
    meta: {
      title: '售前管理',
      icon: 'lock',
      roles: ['admin'] // you can set roles in root nav
    },
    children: [
      
      {
        path: 'reception',
        meta: { 
          title: '接待意向管理',
          icon: 'documentation',
          roles:['admin']
        },
        component: LayoutT2,
        alwaysShow:true,
        children: [
          {
            path: 'recordlist',
            component: () => import('@/views/presale/reception/recordlist'),
            name: 'recordlist',
            meta: { 
              title: '接待记录管理',
              roles:['admin']
            },
          },
          {
            path: 'recorddetails/:id',
            component: () => import('@/views/presale/reception/recorddetails'),
            name: 'recorddetails',
            meta: { 
              title: '接待详情',
              roles:['admin']
            },
            hidden:true
          },
          {
            path: 'receptionanalyze',
            component: () => import('@/views/presale/reception/receptionanalyze'),
            name: 'receptionanalyze',
            meta: { 
              title: '接待分析',
              roles:['admin']
            },
            hidden:true
          },
          {
            path: 'intention',
            component: () => import('@/views/presale/reception/intentionlist'),
            name: 'intention',
            meta: { 
              title: '意向单管理',
              roles:['admin']
            },
          },
          {
            path: 'intentiondetails/:id',
            component: () => import('@/views/presale/reception/intentiondetails'),
            name: 'intentiondetails',
            meta: { 
              title: '意向详情',
              roles:['admin']
            },
            hidden:true
          },
          {
            path: 'intentionanalyze',
            component: () => import('@/views/presale/reception/intentionanalyze'),
            name: 'intentionanalyze',
            meta: { 
              title: '意向分析',
              roles:['admin']
            },
            hidden:true
          },
        ]
      },
      {
        path: 'sales',
        component: LayoutT2,
        alwaysShow:true,
        meta: { 
          title: '销售管理',
          icon: 'documentation',
          roles:['admin']
        },
        children:[
          {
            path: 'contract',
            component: () => import('@/views/presale/sales/contractlist'),
            name: 'contract',
            meta: { 
              title: '销售合同',
              roles:['admin']
            },
          },
          {
            path: 'saleslip',
            component: () => import('@/views/presale/sales/salesliplist'),
            name: 'saleslip',
            meta: { 
              title: '销售单管理',
              roles:['admin']
            },
          },
          {
            path: 'saleslipdetails/:id',
            component: () => import('@/views/presale/sales/saleslipdetails'),
            name: 'saleslipdetails',
            meta: { 
              title: '销售单详情',
              roles:['admin']
            },
            hidden:true
          },
          {
            path: 'saleslipanalyze',
            component: () => import('@/views/presale/sales/saleslipanalyze'),
            name: 'saleslipanalyze',
            meta: { 
              title: '销售单分析',
              roles:['admin']
            },
            hidden:true,
          },
          
        ]
      },
      {
        path: 'agency',
        component: LayoutT2,
        alwaysShow:true,
        meta: { 
          title: '代办业务管理',
          icon: 'documentation',
          roles:['admin']
        },
        children:[
          {
            path: 'taxandregister',
            component: () => import('@/views/presale/agency/taxandregister'),
            name: 'taxandregister',
            meta: { 
              title: '购置税/上牌办理',
              roles:['admin']
            },
          },
          {
            path: 'taxandregisterdetails/:id',
            component: () => import('@/views/presale/agency/taxandregisterdetails'),
            name: 'taxandregisterdetails',
            meta: { 
              title: '待办详情',
              roles:['admin']
            },
            hidden:true
          },
          {
            path: 'registerfeelist',
            component: () => import('@/views/presale/agency/registerfeelist'),
            name: 'registerfeelist',
            meta: { 
              title: '上牌服务费申请',
              roles:['admin']
            },
          },
          {
            path: 'registerfeedetails',
            component: () => import('@/views/presale/agency/registerfeedetails'),
            name: 'registerfeedetailsv',
            meta: { 
              title: '上牌服务费申请详情',
              roles:['admin']
            },
            hidden:true
          },
          {
            path: 'loanlist',
            component: () => import('@/views/presale/agency/loanlist'),
            name: 'loanlist',
            meta: { 
              title: '按揭办理',
              roles:['admin']
            },
          },
          {
            path: 'loandetails',
            component: () => import('@/views/presale/agency/loandetails'),
            name: 'loandetails',
            meta: { 
              title: '按揭详情',
              roles:['admin']
            },
            hidden:true
          },
        ]
      },
      {
        path: 'setting',
        component: LayoutT2,
        alwaysShow:true,
        meta: { 
          title: '销售设置',
          icon: 'documentation',
          roles:['admin']
        },
        children:[
          {
            path: 'presaleattr',
            component: () => import('@/views/presale/setting/presaleattr'),
            name: 'presaleattr',
            meta: { 
              title: '售前属性设置',
              roles:['admin']
            },
          },
          {
            path: 'salestaskindex',
            component: () => import('@/views/presale/setting/salestaskindex'),
            name: 'salestaskindex',
            meta: { 
              title: '销售任务设置',
              roles:['admin']
            },
          },
          {
            path: 'carprice',
            component: () => import('@/views/presale/setting/carprice'),
            name: 'carprice',
            meta: { 
              title: '车辆售价维护',
              roles:['admin']
            },
          },
          {
            path: 'fee',
            component: () => import('@/views/presale/setting/fee'),
            name: 'fee',
            meta: { 
              title: '手续费维护',
              roles:['admin']
            },
          },
        ]
      },
      {
        path: 'analyze',
        component: LayoutT2,
        alwaysShow:true,
        meta: { 
          title: '销售分析',
          icon: 'documentation',
          roles:['admin']
        },
        children:[
          {
            path: 'performanceindex',
            component: () => import('@/views/presale/analyze/performanceindex'),
            name: 'performanceindex',
            meta: { 
              title: '销售业绩分析',
              roles:['admin']
            },
          },
          {
            path: 'performanceother',
            component: () => import('@/views/presale/analyze/performanceother'),
            name: 'performanceother',
            meta: { 
              title: '销售业绩分析(其他)',
              roles:['admin']
            },
          },
          {
            path: 'carprofit', 
            component: () => import('@/views/presale/analyze/carprofit'),
            name: 'carprofit',
            meta: { 
              title: '车辆毛利明细',
              roles:['admin']
            },
          },
        ]
      },
      {
        path: 'activity',
        component: LayoutT2,
        alwaysShow:true,
        meta: { 
          title: '活动管理',
          icon: 'documentation',
          roles:['admin']
        },
        children:[
          {
            path: 'baseitemsetting',
            component: () => import('@/views/presale/activity/baseitemsetting'),
            name: 'baseitemsetting',
            meta: { 
              title: '活动基础项目设置',
              roles:['admin']
            },
          },
          {
            path: 'package',
            component: () => import('@/views/presale/activity/activitypackage'),
            name: 'package',
            meta: { 
              title: '活动套餐',
              roles:['admin']
            },
          },
          {
            path: 'plan', 
            component: () => import('@/views/presale/activity/activityplan'),
            name: 'plan',
            meta: { 
              title: '活动方案',
              roles:['admin']
            },
          },
        ]
      },
    ]
  },

  {
    path: '/aftersalemanage',
    component: Layout,
    alwaysShow: true,
    meta: {
      title: '售后管理',
      icon: 'table',
      roles: ['admin'] // you can set roles in root nav
    },
    children: [
      {
        path: 'allocate',
        meta: { 
          title: '待分配事项',
          icon: 'documentation',
          roles:['admin']
        },
        component: LayoutT2,
        alwaysShow:true,
        children: [
          {
            path: 'carlist',
            component: () => import('@/views/aftersale/allocate/carlist'),
            name: 'carlist1',
            meta: { 
              title: '待分配车辆',
              roles:['admin']
            },
          },
          {
            path: 'addcar',
            component: () => import('@/views/aftersale/allocate/addcar'),
            name: 'addcar',
            meta: { 
              title: '新增车辆信息',
              roles:['admin']
            },
            hidden:true,
          },
          {
            path: 'workorder',
            component: () => import('@/views/aftersale/allocate/workorder'),
            name: 'workorder',
            meta: { 
              title: '工单',
              roles:['admin']
            },
            hidden:true,
          },
        ]
      },
      {
        path: 'keepfitappoint',
        meta: { 
          title: '保养预约',
          icon: 'documentation',
          roles:['admin']
        },
        component: LayoutT2,
        alwaysShow:true,
        children: [
          {
            path: 'appointfollow',
            component: () => import('@/views/aftersale/keepfitappoint/appointfollow'),
            name: 'appointfollow',
            meta: { 
              title: '预约跟进',
              roles:['admin']
            },
          },
          {
            path: 'appointdoing',
            component: () => import('@/views/aftersale/keepfitappoint/appointdoing'),
            name: 'appointdoing',
            meta: { 
              title: '预约单处理',
              roles:['admin']
            },
          },
        ]
      },
      {
        path: 'fixmanage',
        meta: { 
          title: '维修管理',
          icon: 'documentation',
          roles:['admin']
        },
        component: LayoutT2,
        alwaysShow:true,
        children: [
          {
            path: 'constructcommission',
            component: () => import('@/views/aftersale/fixmanage/constructcommission'),
            name: 'constructcommission',
            meta: { 
              title: '施工委托书开设',
              roles:['admin']
            },
          },
          {
            path: 'fitwork',
            component: () => import('@/views/aftersale/fixmanage/fixwork'),
            name: 'fitwork',
            meta: { 
              title: '维修作业',
              roles:['admin']
            },
          },
          {
            path: 'settlement',
            component: () => import('@/views/aftersale/fixmanage/settlement'),
            name: 'settlement',
            meta: { 
              title: '结算收款',
              roles:['admin']
            },
          },
        ]
      },
      {
        path: 'claimdemage',
        meta: { 
          title: '索赔相关',
          icon: 'documentation',
          roles:['admin']
        },
        component: LayoutT2,
        alwaysShow:true,
        children: [
          {
            path: 'adjustment',
            component: () => import('@/views/aftersale/claimdemage/adjustment'),
            name: 'adjustment',
            meta: { 
              title: '索赔调整',
              roles:['admin']
            },
          },
          
        ]
      },
      {
        path: 'carmanage',
        meta: { 
          title: '车辆管理',
          icon: 'documentation',
          roles:['admin']
        },
        component: LayoutT2,
        alwaysShow:true,
        children: [
          {
            path: 'carlist',
            component: () => import('@/views/aftersale/carmanage/carlist'),
            name: 'carlist2',
            meta: { 
              title: '车辆列表',
              roles:['admin']
            },
          },
          {
            path: 'fixhistory',
            component: () => import('@/views/aftersale/carmanage/fixhistory'),
            name: 'fixhistory',
            meta: { 
              title: '维修历史',
              roles:['admin']
            },
            hidden:true,
          },
          {
            path: 'insurance',
            component: () => import('@/views/aftersale/carmanage/insurance'),
            name: 'insurance',
            meta: { 
              title: '车险记录',
              roles:['admin']
            },
            hidden:true,
          },
          {
            path: 'extraparts',
            component: () => import('@/views/aftersale/carmanage/extraparts'),
            name: 'extraparts',
            meta: { 
              title: '加装明细',
              roles:['admin']
            },
            hidden:true,
          },
        ]
      },
      {
        path: 'setting',
        meta: { 
          title: '售后设置',
          icon: 'documentation',
          roles:['admin']
        },
        component: LayoutT2,
        alwaysShow:true,
        children: [
          {
            path: 'fixindex',
            component: () => import('@/views/aftersale/setting/fixindex'),
            name: 'fixindex',
            meta: { 
              title: '项目设置',
              roles:['admin']
            },
          },
          
        ]
      },
    ]
  },
  {
    path: '/finance',
    component: Layout,
    alwaysShow: true,
    meta: {
      title: '财务管理',
      icon: 'chart',
      roles: ['admin'] // you can set roles in root nav
    },
    children: [
      {
        path: 'vehicle',
        meta: { 
          title: '整车业务',
          icon: 'documentation',
          roles:['admin']
        },
        component: LayoutT2,
        alwaysShow:true,
        children: [
          {
            path: 'purchase',
            component: () => import('@/views/finance/vehicle/purchase'),
            name: 'purchase',
            meta: { 
              title: '整车采购业务',
              roles:['admin']
            },
          },
          {
            path: 'sale',
            component: () => import('@/views/finance/vehicle/sale'),
            name: 'sale',
            meta: { 
              title: '整车销售业务',
              roles:['admin']
            },
          },
          {
            path: 'redemptecert',
            component: () => import('@/views/finance/vehicle/redemptecert'),
            name: 'redemptecert',
            meta: { 
              title: '整车赎证业务',
              roles:['admin']
            },
          },
          {
            path: 'carrebate',
            component: () => import('@/views/finance/vehicle/carrebate'),
            name: 'carrebate',
            meta: { 
              title: '整车返利',
              roles:['admin']
            },
          },
          {
            path: 'loanrebate',
            component: () => import('@/views/finance/vehicle/loanrebate'),
            name: 'loanrebate',
            meta: { 
              title: '按揭返利',
              roles:['admin']
            },
          },
          {
            path: 'licensefeeapply',
            component: () => import('@/views/finance/vehicle/licensefeeapply'),
            name: 'licensefeeapply',
            meta: { 
              title: '上牌服务费',
              roles:['admin']
            },
          },
        ]
      },
      {
        path: 'insurance',
        meta: { 
          title: '保险业务',
          icon: 'documentation',
          roles:['admin']
        },
        component: LayoutT2,
        alwaysShow:true,
        children: [
          {
            path: 'renewinsurance',
            component: () => import('@/views/finance/insurance/renewinsurance'),
            name: 'renewinsurance',
            meta: { 
              title: '续保业务',
              roles:['admin']
            },
          },
          {
            path: 'insurancerebate',
            component: () => import('@/views/finance/insurance/insurancerebate'),
            name: 'insurancerebate',
            meta: { 
              title: '车险返利',
              roles:['admin']
            },
          },
          {
            path: 'insurancepay',
            component: () => import('@/views/finance/insurance/insurancepay'),
            name: 'insurancepay',
            meta: { 
              title: '保单支付',
              roles:['admin']
            },
          },
        ]
      },
      {
        path: 'repair',
        meta: { 
          title: '维修业务',
          icon: 'documentation',
          roles:['admin']
        },
        component: LayoutT2,
        alwaysShow:true,
        children: [
          {
            path: 'workorderloan',
            component: () => import('@/views/finance/repair/workorderloan'),
            name: 'workorderloan',
            meta: { 
              title: '工单借款/预收',
              roles:['admin']
            },
          },
          {
            path: 'workordersettlement',
            component: () => import('@/views/finance/repair/workordersettlement'),
            name: 'workordersettlement',
            meta: { 
              title: '工单结算/收款',
              roles:['admin']
            },
          },
          {
            path: 'claimdifference',
            component: () => import('@/views/finance/repair/claimdifference'),
            name: 'claimdifference',
            meta: { 
              title: '索赔差额调整',
              roles:['admin']
            },
          },
          {
            path: 'setmealprepay',
            component: () => import('@/views/finance/repair/setmealprepay'),
            name: 'setmealprepay',
            meta: { 
              title: '套餐预收业务',
              roles:['admin']
            },
          },
        ]
      },
      {
        path: 'parts',
        meta: { 
          title: '配件业务',
          icon: 'documentation',
          roles:['admin']
        },
        component: LayoutT2,
        alwaysShow:true,
        children: [
          {
            path: 'partpurchase',
            component: () => import('@/views/finance/parts/partpurchase'),
            name: 'partpurchase',
            meta: { 
              title: '配件采购业务',
              roles:['admin']
            },
          },
          {
            path: 'rebateaccrual',
            component: () => import('@/views/finance/parts/partrebateaccrual'),
            name: 'rebateaccrual',
            meta: { 
              title: '配件返利计提',
              roles:['admin']
            },
          },
          {
            path: 'rebatereceipt',
            component: () => import('@/views/finance/parts/partrebatereceipt'),
            name: 'rebatereceipt',
            meta: { 
              title: '配件返利实收',
              roles:['admin']
            },
          },
          {
            path: 'partsale',
            component: () => import('@/views/finance/parts/partsale'),
            name: 'partsale',
            meta: { 
              title: '配件直销业务',
              roles:['admin']
            },
          },
          {
            path: 'partrefund',
            component: () => import('@/views/finance/parts/partrefund'),
            name: 'partrefund',
            meta: { 
              title: '配件退货处理',
              roles:['admin']
            },
          },
        ]
      },
      {
        path: 'boutique',
        meta: { 
          title: '精品业务',
          icon: 'documentation',
          roles:['admin']
        },
        component: LayoutT2,
        alwaysShow:true,
        children: [
          {
            path: 'boutiquepurchase',
            component: () => import('@/views/finance/boutique/boutiquepurchase'),
            name: 'boutiquepurchase',
            meta: { 
              title: '精品采购业务',
              roles:['admin']
            },
          },
          {
            path: 'boutiquesale',
            component: () => import('@/views/finance/boutique/boutiquesale'),
            name: 'boutiquesale',
            meta: { 
              title: '精品直销业务',
              roles:['admin']
            },
          },
          {
            path: 'boutiquerefund',
            component: () => import('@/views/finance/boutique/boutiquerefund'),
            name: 'boutiquerefund',
            meta: { 
              title: '精品退货处理',
              roles:['admin']
            },
          },
          {
            path: 'boutiqueextra',
            component: () => import('@/views/finance/boutique/boutiqueextra'),
            name: 'boutiqueextra',
            meta: { 
              title: '精品加装支出',
              roles:['admin']
            },
          },
        ]
      },
      {
        path: 'setting',
        meta: { 
          title: '财务设置',
          icon: 'documentation',
          roles:['admin']
        },
        component: LayoutT2,
        alwaysShow:true,
        children: [
          {
            path: 'thirdbank',
            component: () => import('@/views/finance/setting/thirdbank'),
            name: 'thirdbank',
            meta: { 
              title: '第三方融资银行设置',
              roles:['admin']
            },
          },
          {
            path: 'loanbank',
            component: () => import('@/views/finance/setting/loanbank'),
            name: 'loanbank',
            meta: { 
              title: '按揭金融机构设置',
              roles:['admin']
            },
          },
          {
            path: 'lowbilling',
            component: () => import('@/views/finance/setting/lowbilling'),
            name: 'lowbilling',
            meta: { 
              title: '最低开票价维护',
              roles:['admin']
            },
          },
          {
            path: 'creditagreement',
            component: () => import('@/views/finance/setting/creditagreement'),
            name: 'creditagreement',
            meta: { 
              title: '挂账协议设置',
              roles:['admin']
            },
          },
          {
            path: 'others',
            component: () => import('@/views/finance/setting/others'),
            name: 'others',
            meta: { 
              title: '其他设置',
              roles:['admin']
            },
          },
        ]
      },
      {
        path: 'account',
        meta: { 
          title: '账户设置',
          icon: 'documentation',
          roles:['admin']
        },
        component: LayoutT2,
        alwaysShow:true,
        children: [
          {
            path: 'companybank',
            component: () => import('@/views/finance/account/companybank'),
            name: 'companybank',
            meta: { 
              title: '公司开户行设置',
              roles:['admin']
            },
          },
          {
            path: 'contactcompany',
            component: () => import('@/views/finance/account/contactcompany'),
            name: 'contactcompany',
            meta: { 
              title: '往来单位设置',
              roles:['admin']
            },
          },
          {
            path: 'receiptitem',
            component: () => import('@/views/finance/account/receiptitem'),
            name: 'receiptitem',
            meta: { 
              title: '收入项目设置',
              roles:['admin']
            },
          },
        ]
      },
      {
        path: 'fixedassets',
        meta: { 
          title: '固定资产',
          icon: 'documentation',
          roles:['admin']
        },
        component: LayoutT2,
        alwaysShow:true,
        children: [
          {
            path: 'loanmoney',
            component: () => import('@/views/finance/fixedassets/loanmoney'),
            name: 'loanmoney',
            meta: { 
              title: '借款相关',
              roles:['admin']
            },
          },
          {
            path: 'fixedreimburse',
            component: () => import('@/views/finance/fixedassets/fixedreimburse'),
            name: 'fixedreimburse',
            meta: { 
              title: '固定资产报销',
              roles:['admin']
            },
          },
          {
            path: 'fixedmanage',
            component: () => import('@/views/finance/fixedassets/fixedmanage'),
            name: 'fixedmanage',
            meta: { 
              title: '固定资产管理',
              roles:['admin']
            },
          },
        ]
      },
    ]
  },
  {
    path: '/workshop',
    component: LayoutT1,
    alwaysShow: true,
    meta: {
      title: '车间管理',
      icon: 'lock',
      roles: ['admin'] // you can set roles in root nav
    },
    children: [   
      {
        path: 'jobs',
        component: () => import('@/views/workshop/jobs'),
        name: 'jobs',
        meta: { 
          title: '车间作业',
          roles:['admin']
        }
      },
      {
        path: 'quality',
        component: () => import('@/views/workshop/quality'),
        name: 'quality',
        meta: { 
          title: '完工质检',
          roles:['admin']
        }
      },
    ]
  },
  {
    path: '/cars',
    component: LayoutT1,
    alwaysShow: true,
    meta: {
      title: '整车管理',
      icon: 'lock',
      roles: ['admin'] // you can set roles in root nav
    },
    children: [   
      {
        path: 'carpurchase',
        component: () => import('@/views/cars/carpurchase'),
        name: 'carpurchase',
        meta: { 
          title: '整车采购管理',
          roles:['admin']
        }
      },
      {
        path: 'caronstore',
        component: () => import('@/views/cars/caronstore'),
        name: 'caronstore',
        meta: { 
          title: '整车在库管理',
          roles:['admin']
        }
      },
      {
        path: 'cardetails/:id',
        component: () => import('@/views/cars/cardetails'),
        name: 'cardetails',
        meta: { 
          title: '车辆信息详情',
          roles:['admin']
        },
        hidden:true,
      },
      {
        path: 'caroutstore',
        component: () => import('@/views/cars/caroutstore'),
        name: 'caroutstore',
        meta: { 
          title: '订单配车管理',
          roles:['admin']
        }
      },
      {
        path: 'caroutstoredetails/:id',
        component: () => import('@/views/cars/caroutstoredetails'),
        name: 'caroutstoredetails',
        meta: { 
          title: '订单配车详情',
          roles:['admin']
        },
        hidden:true,
      },
      {
        path: 'caroutstoreextra',
        component: () => import('@/views/cars/caroutstoreextra'),
        name: 'caroutstoreextra',
        meta: { 
          title: '出库事项处理',
          roles:['admin']
        }
      },
      {
        path: 'setting',
        component: LayoutT2,
        alwaysShow:true,
        meta: { 
          title: '车辆设置',
          icon: 'documentation',
          roles:['admin']
        },
        children:[
          {
            path: 'carattr',
            component: () => import('@/views/cars/carattribute'),
            name: 'carattribute',
            meta: { 
              title: '车辆属性设置',
              roles:['admin']
            },
          },
          {
            path: 'cardefine',
            component: () => import('@/views/cars/cardefine'),
            name: 'cardefine',
            meta: { 
              title: '车辆商品定义',
              roles:['admin']
            },
          },
          {
            path: 'carwarehouse',
            component: () => import('@/views/cars/carwarehouse'),
            name: 'carwarehouse',
            meta: { 
              title: '车辆仓库设置',
              roles:['admin']
            },
          },
          {
            path: 'carsupplier',
            component: () => import('@/views/cars/carxsupplier'),
            name: 'carsupplier',
            meta: { 
              title: '车辆供应商设置',
              roles:['admin']
            },
          },
        ]
      },
    ]
  },
  {
    path: '/parts',
    component: LayoutT1,
    alwaysShow: true,
    meta: {
      title: '配件管理',
      icon: 'lock',
      roles: ['admin'] // you can set roles in root nav
    },
    children: [   
      {
        path: 'partpurchase',
        component: () => import('@/views/parts/partpurchase'),
        name: 'partpurchase',
        meta: { 
          title: '配件采购入库',
          roles:['admin']
        }
      },
      {
        path: 'partpurchaseother',
        component: () => import('@/views/parts/partpurchaseother'),
        name: 'partpurchaseother',
        meta: { 
          title: '配件其他入库',
          roles:['admin']
        }
      },
      {
        path: 'partoutstore',
        component: () => import('@/views/parts/partoutstore'),
        name: 'partoutstore',
        meta: { 
          title: '配件工单出库',
          roles:['admin']
        }
      },
      {
        path: 'partoutstoreother',
        component: () => import('@/views/parts/partoutstoreother'),
        name: 'partoutstoreother',
        meta: { 
          title: '配件其它出库',
          roles:['admin']
        }
      },
      {
        path: 'partonstore',
        component: () => import('@/views/parts/partonstore'),
        name: 'partonstore',
        meta: { 
          title: '配件在库管理',
          roles:['admin']
        }
      },
      {
        path: 'setting',
        component: LayoutT2,
        alwaysShow:true,
        meta: { 
          title: '配件设置',
          icon: 'documentation',
          roles:['admin']
        },
        children:[
          {
            path: 'partattr',
            component: () => import('@/views/parts/partattribute'),
            name: 'partattribute',
            meta: { 
              title: '配件属性设置',
              roles:['admin']
            },
          },
          {
            path: 'partdefine',
            component: () => import('@/views/parts/partdefine'),
            name: 'partdefine',
            meta: { 
              title: '配件定义设置',
              roles:['admin']
            },
          },
          {
            path: 'partworkshop',
            component: () => import('@/views/parts/partworkshop'),
            name: 'partworkshop',
            meta: { 
              title: '配件仓库设置',
              roles:['admin']
            },
          },
          {
            path: 'partxsupplier',
            component: () => import('@/views/parts/partxsupplier'),
            name: 'partxsupplier',
            meta: { 
              title: '配件供应商设置',
              roles:['admin']
            },
          },
        ]
      },
    ]
  },
  {
    path: '/boutique',
    component: LayoutT1,
    alwaysShow: true,
    meta: {
      title: '精品管理',
      icon: 'lock',
      roles: ['admin'] // you can set roles in root nav
    },
    children: [   
      {
        path: 'boutiquepurchase',
        component: () => import('@/views/boutique/boutiquepurchase'),
        name: 'boutiquepurchase',
        meta: { 
          title: '精品入库管理',
          roles:['admin']
        }
      },
      {
        path: 'purchasesettlement',
        component: () => import('@/views/boutique/purchasesettlement'),
        name: 'purchasesettlement',
        meta: { 
          title: '采购结算处理',
          roles:['admin']
        }
      },
      {
        path: 'boutiqueoutstore',
        component: () => import('@/views/boutique/boutiqueoutstore'),
        name: 'boutiqueoutstore',
        meta: { 
          title: '精品加装/出售出库',
          roles:['admin']
        }
      },
      {
        path: 'boutiqueoutstoreother',
        component: () => import('@/views/boutique/boutiqueoutstoreother'),
        name: 'boutiqueoutstoreother',
        meta: { 
          title: '精品其它出库',
          roles:['admin']
        }
      },
      {
        path: 'boutiquesalelist',
        component: () => import('@/views/boutique/boutiquesalelist'),
        name: 'boutiquesalelist',
        meta: { 
          title: '精品改/加装单明细',
          roles:['admin']
        }
      },
      {
        path: 'boutiqueonstore',
        component: () => import('@/views/boutique/boutiqueonstore'),
        name: 'boutiqueonstore',
        meta: { 
          title: '精品在库管理',
          roles:['admin']
        }
      },
      {
        path: 'boutiquedetails',
        component: () => import('@/views/boutique/boutiquedetails'),
        name: 'boutiquedetails',
        meta: { 
          title: '出入库明细',
          roles:['admin']
        },
        hidden:true,
      },
      {
        path: 'setting',
        component: LayoutT2,
        alwaysShow:true,
        meta: { 
          title: '精品设置',
          icon: 'documentation',
          roles:['admin']
        },
        children:[
          {
            path: 'boutiqueattr',
            component: () => import('@/views/boutique/setting/boutiqueattribute'),
            name: 'boutiqueattribute',
            meta: { 
              title: '精品属性设置',
              roles:['admin']
            },
          },
          {
            path: 'boutiquedefine',
            component: () => import('@/views/boutique/setting/boutiquedefine'),
            name: 'boutiquedefine',
            meta: { 
              title: '精品定义设置',
              roles:['admin']
            },
          },
          {
            path: 'boutiquesetmeal',
            component: () => import('@/views/boutique/setting/boutiquesetmeal'),
            name: 'boutiquesetmeal',
            meta: { 
              title: '精品套餐设置',
              roles:['admin']
            },
          },
          {
            path: 'boutiquewarehouse',
            component: () => import('@/views/boutique/setting/boutiquewarehouse'),
            name: 'boutiquewarehouse',
            meta: { 
              title: '精品仓库设置',
              roles:['admin']
            },
          },
          {
            path: 'boutiquesupplier',
            component: () => import('@/views/boutique/setting/boutiquesupplier'),
            name: 'boutiquesupplier',
            meta: { 
              title: '精品供应商设置',
              roles:['admin']
            },
          },
        ]
      },
    ]
  },
  {
    path: '/insurance',
    component: LayoutT1,
    alwaysShow: true,
    meta: {
      title: '保险业务',
      icon: 'bug',
      roles: ['admin'] // you can set roles in root nav
    },
    children: [
      {
        path:'distribute',
        component: LayoutT2,
        alwaysShow:true,
        meta: { 
          title: '业务分配',
          icon: 'documentation',
          roles:['admin']
        },
        children:[
          {
            path: 'newinsurance',
            component: () => import('@/views/insurance/distribute/newinsurance'),
            name: 'newinsurance',
            meta: { 
              title: '新保分配',
              roles:['admin']
            }
          },
          {
            path: 'renewinsurance',
            component: () => import('@/views/insurance/distribute/renewinsurance'),
            name: 'renewinsurance',
            meta: { 
              title: '续保分配',
              roles:['admin']
            }
          },
        ]
      },
      {
        path:'processing',
        component: LayoutT2,
        alwaysShow:true,
        meta: { 
          title: '业务处理',
          icon: 'documentation',
          roles:['admin']
        },
        children:[
          {
            path: 'renewfollow',
            component: () => import('@/views/insurance/processing/renewfollow'),
            name: 'renewfollow',
            meta: { 
              title: '续保跟单',
              roles:['admin']
            }
          },
          {
            path: 'insurancehandle',
            component: () => import('@/views/insurance/processing/insurancehandle'),
            name: 'insurancehandle',
            meta: { 
              title: '保单处理',
              roles:['admin']
            }
          },
          {
            path: 'rebatehandle',
            component: () => import('@/views/insurance/processing/rebatehandle'),
            name: 'rebatehandle',
            meta: { 
              title: '返利处理',
              roles:['admin']
            }
          },
        ]
      },
      {
        path:'carinsurance',
        component: LayoutT2,
        alwaysShow:true,
        meta: { 
          title: '业务分配',
          icon: 'documentation',
          roles:['admin']
        },
        children:[
          {
            path: 'insurancequery',
            component: () => import('@/views/insurance/carinsurance/insurancequery'),
            name: 'insurancequery',
            meta: { 
              title: '车险查询',
              roles:['admin']
            }
          },
          
        ]
      },
      {
        path:'setting',
        component: LayoutT2,
        alwaysShow:true,
        meta: { 
          title: '保险设置',
          icon: 'documentation',
          roles:['admin']
        },
        children:[
          {
            path: 'shopinsurance',
            component: () => import('@/views/insurance/setting/shopinsurance'),
            name: 'shopinsurance',
            meta: { 
              title: '本店险设置',
              roles:['admin']
            }
          },
          {
            path: 'companyinsurance',
            component: () => import('@/views/insurance/setting/companyinsurance'),
            name: 'companyinsurance',
            meta: { 
              title: '保险公司设置',
              roles:['admin']
            }
          },
        ]
      },
    ]
  },
  {
    path: '/company',
    component: Layout,
    alwaysShow: true,
    meta: {
      title: '公司管理',
      icon: 'bug',
      roles: ['admin'] // you can set roles in root nav
    },
    children: [
      {
        path: 'staff',
        component: () => import('@/views/company/staff'),
        name: 'staff',
        meta: { 
          title: '员工信息',
          roles:['admin']
        }
      },
      {
        path: 'depart',
        component: () => import('@/views/company/depart'),
        name: 'depart',
        meta: { 
          title: '部门信息',
          roles:['admin']
        }
      },
      {
        path: 'role',
        component: () => import('@/views/company/role'),
        name: 'role',
        meta: { 
          title: '角色信息',
          roles:['admin']
        }
      },
      {
        path: 'performance',
        component: () => import('@/views/company/performance'),
        name: 'performance',
        meta: { 
          title: '绩效考评',
          roles:['admin']
        }
      },
      
    ]
  },
  {
    path: '/logmanage',
    component: Layout,
    alwaysShow: true,
    meta: {
      title: '日志管理',
      icon: 'bug',
      roles: ['admin'] // you can set roles in root nav
    },
    children: [
      {
        path: 'smsloglist',
        component: () => import('@/views/log/smsloglist'),
        name: 'smsloglist',
        meta: { 
          title: '短信日志',
          roles:['admin']
        }
      },
      {
        path: 'systemtasklist',
        component: () => import('@/views/log/systemtasklist'),
        name: 'systemtasklist',
        meta: { 
          title: '任务日志',
          roles:['admin']
        }
      },
      {
        path: 'errorloglist',
        component: () => import('@/views/log/errorloglist'),
        name: 'errorloglist',
        meta: { 
          title: '错误日志',
          roles:['admin']
        }
      },
      {
        path: 'adminloglist',
        component: () => import('@/views/log/adminloglist'),
        name: 'adminloglist',
        meta: { 
          title: '管理员日志',
          roles:['admin']
        }
      },
      {
        path: 'systemloglist',
        component: () => import('@/views/log/systemloglist'),
        name: 'systemloglist',
        meta: { 
          title: '系统日志',
          roles:['admin']
        }
      },
    ]
  },
  // {
  //   path: '/icon',
  //   component: Layout,
  //   children: [
  //     {
  //       path: 'index',
  //       component: () => import('@/views/icons/index'),
  //       name: 'Icons',
  //       meta: { title: 'Icons', icon: 'icon', noCache: true }
  //     }
  //   ],
  // },

  // 404 page must be placed at the end !!!
  { path: '*', redirect: '/404', hidden: true }
]

const createRouter = () => new Router({
  // mode: 'history', // require service support
  scrollBehavior: () => ({ y: 0 }),
  routes: constantRoutes
})

const router = createRouter()

// Detail see: https://github.com/vuejs/vue-router/issues/1234#issuecomment-357941465
export function resetRouter() {
  const newRouter = createRouter()
  router.matcher = newRouter.matcher // reset router
}

export default router
